﻿#include "mainwindow.h"

#include <QApplication>
#include <QFile>
#include <QDebug>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    // 加载配置的QSS文件
    const char* filename = ":/style/stylesheet.qss";
    QFile qss(filename);
    if (qss.open(QFile::ReadOnly)) {
        qDebug("open file success......");
        QString style = QLatin1String(qss.readAll());
        a.setStyleSheet(style);
    } else {
        qDebug("open failed......");
    }

    // 加载配置文件
    // 获取当前应用程序的路径
    QString app_path = QCoreApplication::applicationDirPath();
    // 拼接文件名
    QString fileName = "config.ini";
    QString config_path = QDir::toNativeSeparators(app_path + QDir::separator() + fileName);

    QSettings settings(config_path, QSettings::IniFormat);
    QString gate_host = settings.value("GateServer/host").toString();
    QString gate_port = settings.value("GateServer/port").toString();
    gate_url_prefix = "http://" + gate_host + ":" + gate_port;

    MainWindow w;
    w.show();
    return a.exec();
}
